package fr.poy.mygluco.model;

import java.io.Serializable;
import java.util.Date;

import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

import com.extjs.gxt.ui.client.data.BeanModelTag;
import com.extjs.gxt.ui.client.widget.form.Time;

@PersistenceCapable//(identityType = IdentityType.APPLICATION)
@SuppressWarnings("serial")
public class Record implements BeanModelTag,Serializable {
	
	//public static enum SOURCE{ METER  , MANUAL , METER_MANUAL,XMPP, ...	} ; 
	
	@PrimaryKey
    @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY  )
	private Long id;
	private String userEmail; 
	
	private Integer day;
	private Date date;
	private Integer time;
	
	//private SOURCE source; 
	private Integer bg;
	private String comment;
	private String event;//auto complete 
	/*(acétonurie, glycosurie, hypo, fièvre, maladie,
	évènements particuliers
	● TO = injection oubliée
	● E+ = exercice physique inhabituel
	● A+ = repas exceptionnel
	● A– = repas non pris
	● Prise d’autres médicaments…)*/
	
	private String flag;//character flag from meter
	
	private Integer ins1;
	private Integer ins2;
	private Integer ins3;
	 
	//private Boolean exclude=false;//TODO ajouter exclusion anomalie
	
	
	
	public Record() {
	}
 

	
	public Record(String userEmail, Integer day, Date date, Integer time, Integer bg, String comment, String event, String flag, Integer ins1, Integer ins2,
			Integer ins3) {
		super();
		this.userEmail = userEmail;
		this.day = day;
		this.date = date;
		this.time = time; 
		this.bg = bg;
		this.comment = comment;
		this.event = event;
		this.flag = flag;
		this.ins1 = ins1;
		this.ins2 = ins2;
		this.ins3 = ins3; 
	}

	public Time getGxtTime() {
		if(time<=0) return new Time(0, 0);
		return new Time(time/60, time%60);
	}

	public void setGxtTime(Time time) {//BUG GXT ?
		if(time==null)return;
		this.time = time.getHour()*60+time.getMinutes(); 
	}
	
	
	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public int getDay() {
		return day;
	}

	public void setDay(int day) {
		this.day = day;
	}

	public Date getDate() {
		return date;
	}

	public void setDate(Date date) {
		this.date = date;
	}

	public int getTime() {
		return time;
	}

	public void setTime(int time) {
		this.time = time;
	}
 
	public Integer getBg() {
		return bg;
	}

	public void setBg(Integer bg) {
		this.bg = bg;
	}

	public String getComment() {
		return comment;
	}

	public void setComment(String comment) {
		this.comment = comment;
	}

	public String getEvent() {
		return event;
	}

	public void setEvent(String event) {
		this.event = event;
	}

	public String getFlag() {
		return flag;
	}

	public void setFlag(String flag) {
		this.flag = flag;
	}

 

	public Integer getIns1() {
		return ins1;
	}

	public void setIns1(Integer ins1) {
		this.ins1 = ins1;
	}

	public Integer getIns2() {
		return ins2;
	}

	public void setIns2(Integer ins2) {
		this.ins2 = ins2;
	}

	public Integer getIns3() {
		return ins3;
	}

	public void setIns3(Integer ins3) {
		this.ins3 = ins3;
	}

	public String getUserEmail() {
		return userEmail;
	}



	public void setUserEmail(String userEmail) {
		this.userEmail = userEmail;
	}


 
 



	





 
  

}
